﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Ppt = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Tools;
using ViewComponents.PowerPoint;

namespace PSCharts
{
    public class UIManager
    {
        readonly Ppt.Application mApp = Globals.ThisAddIn.Application;

        public void Launch()
        {
            HookUpEvents();
        }

        void CreateUI(Ppt.Presentation pres)
        {
            // Create a user control to contain the WPF element host.
            UserControl uc = new WPFHostControl();

            // Create a custom task pane.
            CustomTaskPane ctp = Globals.ThisAddIn.CustomTaskPanes.Add(uc, "PS Charts Add-In");
            ctp.Visible = true;
        }

        void HookUpEvents()
        {
            mApp.AfterNewPresentation += App_AfterNewPresentation;
            mApp.PresentationOpen += App_PresentationOpen;
        }

        void App_AfterNewPresentation(Ppt.Presentation Pres)
        {
            CreateUI(Pres);
        }

        void  App_PresentationOpen(Ppt.Presentation Pres)
        {
            CreateUI(Pres);
        }
    }
}
